#!/usr/bin/env python 
# -*- coding:utf-8 -*-
"""
@Time:2021/12/13 3:24 下午"
@Author:lydia_liu"
@File:operate_cookie.py
@function:
"""
import time

import yaml
from selenium import webdriver


class TestCookie:
    def setup(self):
        self.driver = webdriver.Chrome()

    def test_save_cookie(self):
        #访问企业微信主页
        self.driver.get('https://work.weixin.qq.com/wework_admin/loginpage_wx?from=myhome')
        time.sleep(10)
        #等登陆成功后获取cookie信息
        cookies = self.driver.get_cookies()
        for cookie in cookies:

            print(cookie)

        #将cookie存入一个本地文件
        with open('cookie.yaml','w') as f:
            yaml.safe_dump(cookies,f)